package com.zyguo.sdk.websocket;

import java.io.Serializable;
import java.util.concurrent.atomic.AtomicLong;

import org.msgpack.annotation.Message;

@Message
public class RequestHeader implements Serializable {
	private static final long serialVersionUID = -7047211371081113949L;
	private static AtomicLong requestId = new AtomicLong();
	private int msgType; // 4个字节
	private int userId;  // 4个字节
	private long msgId;  // 8个字节

	public RequestHeader(){
	}
	
	public RequestHeader(int msgType, int userId ) {
		this.setUserId(userId);
		this.setMsgType(msgType);
		this.setMsgId(requestId.getAndIncrement());
	}
	
	public RequestHeader(int msgType, int userId, long msgId ) {
		this.setUserId(userId);
		this.setMsgType(msgType);
		this.setMsgId(msgId);
	}
	

	@Override
	public String toString() {
		return this.getUserId() + ":" + this.getMsgType() + ":" + this.getMsgId();
	}

	public int getMsgType() {
		return msgType;
	}

	public void setMsgType(int msgType) {
		this.msgType = msgType;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public long getMsgId() {
		return msgId;
	}

	public void setMsgId(long msgId) {
		this.msgId = msgId;
	}
}
